

<%@ page import="com.surelution.projects.crm.MarketTracking" %>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <meta name="layout" content="main" />
        <g:set var="entityName" value="${message(code: 'marketTracking.label', default: 'MarketTracking')}" />
        <title><g:message code="default.edit.label" args="[entityName]" /></title>
    </head>
    <body>
        <div class="nav">
            <span class="menuButton"><a class="home" href="${createLink(uri: '/')}"><g:message code="default.home.label"/></a></span>
        </div>
        <div class="body">
            <h1><g:message code="default.edit.label" args="[entityName]" /></h1>
            <g:if test="${flash.message}">
            <div class="message">${flash.message}</div>
            </g:if>
            <g:hasErrors bean="${marketTrackingInstance}">
            <div class="errors">
                <g:renderErrors bean="${marketTrackingInstance}" as="list" />
            </div>
            </g:hasErrors>
            <g:form method="post" >
                <g:hiddenField name="id" value="${marketTrackingInstance?.id}" />
                <g:hiddenField name="version" value="${marketTrackingInstance?.version}" />
                <div class="dialog">
                    <table>
                        <tbody>
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                  <label for="market"><g:message code="marketTracking.market.label" default="Market" /></label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: marketTrackingInstance, field: 'market', 'errors')}">
                                    <g:select name="market.id" from="${com.surelution.projects.crm.Market.list()}" optionKey="id" optionValue="name" value="${marketTrackingInstance?.market?.id}"  />
                                </td>
                            </tr>
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                  <label for="handleTime"><g:message code="marketTracking.handleTime.label" default="Handle Time" /></label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: marketTrackingInstance, field: 'handleTime', 'errors')}">
                                    <g:datePicker name="handleTime" precision="day" value="${marketTrackingInstance?.handleTime}"  />
                                </td>
                            </tr>
                        
                        	<tr class="prop">
                                <td valign="top" class="name">
                                  <label for="reason"><g:message code="marketTracking.reason.label" default="Reason" /></label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: marketTrackingInstance, field: 'reason', 'errors')}">
                                    <g:select name="reason.id" from="${com.surelution.projects.crm.MarketTrackingReason.list()}" optionKey="id" optionValue="title" value="${marketTrackingInstance?.reason?.id}"  />
                                </td>
                            </tr>
                            
                            <tr class="prop">
                                <td valign="top" class="name">
                                  <label for="description"><g:message code="marketTracking.description.label" default="Description" /></label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: marketTrackingInstance, field: 'description', 'errors')}">
                                    <g:textArea name="description" rows="5" cols="30" value="${marketTrackingInstance?.description}" />
                                </td>
                            </tr>
                            
                            <tr class="prop">
                                <td valign="top" class="name">
                                  <label for="needFollowup"><g:message code="marketTracking.needFollowup.label" default="Need Followup" /></label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: marketTrackingInstance, field: 'needFollowup', 'errors')}">
                                    <g:checkBox name="needFollowup" value="${marketTrackingInstance?.needFollowup}" />
                                </td>
                            </tr>
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                  <label for="preTracking"><g:message code="marketTracking.preTracking.label" default="Pre Tracking" /></label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: marketTrackingInstance, field: 'preTracking', 'errors')}">
                                	<g:select name="preTracking.id" noSelection="['':'']" from="${com.surelution.projects.crm.MarketTracking.findAllByMarketAndNeedFollowup(marketInstance,true).sort{-it.handleTime.time}}" optionKey="id" optionValue='${{it.handler.username + "," + it.handleTime.format("yyyy-MM-dd")}}'/>
                                </td>
                            </tr>
                        
                        </tbody>
                    </table>
                </div>
                <div class="buttons">
                    <span class="button"><g:actionSubmit class="save" action="update" value="${message(code: 'default.button.update.label', default: 'Update')}" /></span>
                    <span class="button"><g:actionSubmit class="delete" action="delete" value="${message(code: 'default.button.delete.label', default: 'Delete')}" onclick="return confirm('${message(code: 'default.button.delete.confirm.message', default: 'Are you sure?')}');" /></span>
                </div>
            </g:form>
        </div>
    </body>
</html>
